<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<table id="workflow_page" class="table table-bordered">
</table>
<script type="text/javascript">
    var workflowId = '${workflowId}';
    $(function () {
        var workflow_page = $('#workflow_page').datagrid({
            height: '100%',
            width:'100%',
            fullGrid:true,
            columnMenu: false,
            contextMenuH:false,
            fieldSortable:false,
            gridTitle: '业务链记录',
            showToolbar: true,
            toolbarItem: "refresh",
            filterThead: false,
            delPK: 'id',
            dataUrl: '/service/chain/workflow/'+workflowId,
            local: "remote",
            inlineEditMult: false,
            saveAll: false,
            addLocation: 'last',
            paging:false,
            columns: [
                {
                    name: 'nodeName',
                    label: '名称',
                    align: 'center',
                    rule: 'required',
                    add: false
                }, {
                    name: 'status',
                    align: 'center',
                    label: '状态'
                }, {
                    name: 'orderNo',
                    align: 'center',
                    label: '订单号'
                }, {
                    name: 'sort',
                    align: 'center',
                    label: '所属步骤'
                }, {
                    name: 'result',
                    label: '结果',
                    align: 'center'
                }, {
                    render: operation,
                    label: '操作列'
                }
            ],
            linenumberAll: true
        });

    });

    function operation(value, data) {
        var html = '<button type="button" class="btn-green" onclick="checkParams(\'' + data.sort + '\',\''+data.nodeName+'\');">参数</button>';
        if(data.status === 2){
            html += '<button type="button" class="btn-green" onclick="execute();">执行</button>';
        }
        return html
    }

   function checkParams(sort,nodeName) {
       var nodeDialog = BJUI.dialog({
           id:'node_'+sort,
           url:'/service/chain/nodeParams/'+workflowId+'-'+sort,
           title:nodeName,
           width:800,
           height:600
       });
   }

   function execute(){
        alert(1);
//       executeAgain
        //workflowId
       BJUI.ajax('doajax', {
           url: '/service/chain/executeAgain/'+workflowId,
           validate: true,
           loadingmask: true,
           callback: function (response, options) {
              alert(response);
           }
       });
   }

</script>